package 算法;

import java.util.Comparator;
import java.util.TreeMap;

/**
 * @author lo
 * @date 2021/11/8
 */
public class Text2 {
    public static void main(String[] args) {
        //Character c = 'A';
        //Character z = 'z';
        //Character Z = 'Z';
        //System.out.println(c.hashCode());
        //System.out.println(z.hashCode());
        //System.out.println(Z.hashCode());
        String text = "ddcGGGccbAaHHHH";
        company(text);
    }

    public static void company(String text){
        TreeMap<Character, Integer> result = new TreeMap<>(new Comparator<Character>() {
            @Override
            public int compare(Character o1, Character o2) {
                if(o1 >= 97 && o2 >= 97){
                    return o1 - o2;
                }else if(o1 <= 97 && o2 <= 97){
                    return o1 - o2;
                } else{
                    return o2 - o1;
                }
            }
        });
        for(int i = 0; i < text.length(); i++){
            Integer num = result.get(text.charAt(i));
            if(num != null){
                result.put(text.charAt(i), num + 1);
            }else{
                result.put(text.charAt(i), 1);
            }
        }
        System.out.println(result);
    }

}
